package com.project.visitAll;





import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Toast;

public class VisitAll extends Activity {
    /** Called when the activity is first created. */
	CheckBox checkBoxOne=null; 
	CheckBox checkBoxTwo=null;
	CheckBox checkBoxThree=null;
	CheckBox checkBoxFour=null;
	CheckBox checkBoxFive=null;
	MyService myService;
	boolean history;
	boolean nature;
	boolean wildLife;
	boolean sports;
	boolean rel;
	boolean[] val;
    @Override
    public void onCreate(Bundle savedInstanceState) {		//instantiating the visitAll activity
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    	checkBoxOne = (CheckBox) findViewById(R.id.history);
    	checkBoxTwo = (CheckBox) findViewById(R.id.nature);
    	checkBoxThree = (CheckBox) findViewById(R.id.wildLife); 
    	checkBoxFour = (CheckBox) findViewById(R.id.sports);
    	checkBoxFive = (CheckBox) findViewById(R.id.relCul);

        
        MyService.setMainActivity(this);		// pass the reference to the service
      			

        final Intent myservice = new Intent(this, MyService.class);
        final Button button1 = (Button) findViewById(R.id.Button1);			//	ok button         
        button1.setOnClickListener(new View.OnClickListener() {            
        	public void onClick(View v) {		
        	   	history=checkBoxOne.isChecked();
            	nature=checkBoxTwo.isChecked();
           		wildLife=checkBoxThree.isChecked();
            	sports=checkBoxFour.isChecked();
            	rel=checkBoxFive.isChecked();
            	if(!history&!nature&!wildLife&!sports&!rel){		//if no check box is selected
                	Context context = getApplicationContext();
                	String msg = "Please select atleast one feild!";
                	int duration = Toast.LENGTH_SHORT;
                	Toast toast = Toast.makeText(context, msg, duration);
                	toast.show();
                	
            	}
            	else{

            		startService(myservice);		//start the service

            		finish();
            		}

        		}         
        	});
        final Button button2 = (Button) findViewById(R.id.Button2);     // cancel button    
        button2.setOnClickListener(new View.OnClickListener() {             
        	public void onClick(View v) {
        		finish();            //if user presses cancel, exit the application
        		}         
        	});
        final Button button3 = (Button) findViewById(R.id.about);     // about button    
        button3.setOnClickListener(new View.OnClickListener() {             
        	public void onClick(View v) {
        		Intent intent=new Intent(v.getContext(),About.class); 
        		startActivityForResult(intent,0);
        		}         
        	});
    }
    

}